var param_date = $.url().param('date');

getPlatformInfo(param_date);

function getPlatformInfo(date) {
    $("#platform_loading_zone").show();
    $("#platform_data_zone").hide();
    $("#platform_error_zone").hide();
    var token = getCookie('csrftoken');
    $.ajax({
        // url: '/football/get_platform_info/',
        url: 'http://8.134.215.241:9080/jyb/core/plat/acquireplats',
        type: 'POST',
        headers:{'X-CSRFToken': token, "Content-Type": "application/json"},
        data: JSON.stringify({'baseDate': date}),
        success: function(data) {
            let jsonData = data['result']['platVoList'];
            console.log(jsonData);
            let listHtml = "";
            listHtml = listHtml + '<div class="self_common_zone">';
            jsonData.forEach((item, index) => {
                let platform_code = item['platCode'];
                let platform_name = item['platName'];
                listHtml = listHtml + '<div data-date="' + date + '" data-platform="' + platform_code + '" onclick="goToTypePage(this)" class="self_common_item self_common_item_size_normal self_letter_spacing_2">';
                listHtml = listHtml + '<span>';
                listHtml = listHtml + platform_name;
                listHtml = listHtml + '</span>';
                listHtml = listHtml + '</div>';
            });
            listHtml = listHtml + '</div>';
            $("#platform_data_zone").html(listHtml);
            $("#platform_loading_zone").hide();
            $("#platform_error_zone").hide();
            $("#platform_data_zone").show();
        },
        error: function() {
            $("#platform_loading_zone").hide();
            $("#platform_data_zone").hide();
            $("#platform_error_zone").show();
        }
    });
}

function goToTypePage(element) {
    const date = element.dataset.date;
    const platform_code = element.dataset.platform;
    goToOtherPage('./type.html?platform_code=' + platform_code + '&date=' + date );
}